package com.zbkj.crmeb.merchant.admin.controller;

import com.crmeb.core.common.CommonResult;
import com.zbkj.crmeb.statistics.response.SupplierRankingResponse;
import com.zbkj.crmeb.statistics.response.SupplierSalesResponse;
import com.zbkj.crmeb.statistics.service.HomeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;


/**
 * 统计 -- 主页 前端控制器
 */
@Slf4j
@RestController
@RequestMapping("api/admin/supplier/statistics/home")
@Api(tags = "供应商 -- 主页")
public class SupplierHomeController extends AdminBaseController {

    @Autowired
    private HomeService homeService;

    @ApiOperation(value = "交易金额")
    @GetMapping(value = "/sales")
    public CommonResult<SupplierSalesResponse> supplierSales(HttpServletRequest request){
        return CommonResult.success(homeService.supplierSales(getMerId(request)));
    }

    @ApiOperation(value = "品牌排行")
    @GetMapping(value = "/brand/ranking")
    public CommonResult<List<SupplierRankingResponse>> brandRanking(@ApiParam(value="日期选择  本日:today  本周:week  本月:month ", required = true)String dateLimit, HttpServletRequest request){
        return CommonResult.success(homeService.brandRanking(dateLimit,getMerId(request)));
    }

    @ApiOperation(value = "商品排行")
    @GetMapping(value = "/product/ranking")
    public CommonResult<List<SupplierRankingResponse>> productRanking(@ApiParam(value="日期选择  本日:today  本周:week  本月:month ", required = true)String dateLimit, HttpServletRequest request){
        return CommonResult.success(homeService.productRanking(dateLimit,getMerId(request)));
    }

}



